﻿using System;
using System.Reflection;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;

namespace AnyOffice.general.mytable
{
    public partial class nofity : System.Web.UI.UserControl
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(ConfigManager.ConnectionString);
                NotifyDao dao = new NotifyDao();
                UserCache cache = new UserCache();
                DataTable table = dao.SelectMyTable(conn, cache.DeptId, cache.PrivId, cache.UserId);
                if (table.Rows.Count > 0)
                {
                    this.rptNotify.DataSource = table;
                    this.rptNotify.DataBind();
                }
                else
                {
                    this.litNotify.Text = "·暂无公告通知";
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("", exception);
                }
            }
        }
        public string GetNew(string readers)
        {
            readers = "," + readers + ",";
            if (readers.IndexOf("," + new UserCache().UserId + ",") < 0)
            {
                return "<img src=/images/new.gif align=absmiddle>";
            }
            return string.Empty;
        }
    }
}